/**
 * @作者 伟子涵
 * @微信公号 搬砖暗夜码农
 * @开源项目 $ https://gitee.com/zhouwei5208888
 * @我的博客 $ http://itzhouwei.com
 * @创建时间 2023/11/30 18:37
 */
package com.itzhouwei.mybatis.binding;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Proxy;
import java.util.Map;

/**
 * @description: @MapperProxyFactory 映射器代理工厂
 * @author：zw，微信：yingshengzw
 * @date: 2023/11/30 18:37
 * @Copyright： 公众号：搬砖暗夜码农 | 博客：https://itzhouwei.com - 沉淀、分享、成长，让自己和他人都能有所收获！
 */
@SuppressWarnings("all")
@Slf4j
public class MapperProxyFactory<T> {

    private final  Class<T> mapperInterface;

   public  MapperProxyFactory(Class<T> mapperInterface) {
        this.mapperInterface = mapperInterface;
    }


   public  T newInstance( Map<String,String> sqlSession){
       MapperProxy<T> mapperProxy = new MapperProxy<>(mapperInterface,sqlSession);
      return (T) Proxy.newProxyInstance(mapperProxy.getClass().getClassLoader(),
               new Class[]{mapperInterface},mapperProxy);
   }

}
